<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <script src="./lib/vue.js"></script>
</head>

<body>
    <div id="app">
        <!-- v-if 有较高的切换性能消耗,每次都是删除/新增元素 -->
        <h1 v-if="flag">我是v-if控制的</h1>
        <!-- v-show 有较高的渲染性能消耗 每次都是改变的display:none样式 -->
        <h1 v-show="flag">我是v-show控制的</h1>
        <button @click="trigger()">trigger</button>
        <button @click="flag=!flag">trigger</button>
    </div>
</body>
<script>
    var vm = new Vue({
        el: "#app",
        data: {
            flag: true,
        },
        methods: {
            trigger() {
                this.flag = !this.flag;
            }
        }
    });
</script>

</html>